package com.gxa.autoparts.admin.service.impl;

import com.gxa.autoparts.admin.mapper.OrderMapper;
import com.gxa.autoparts.admin.service.OrderService;
import com.gxa.autoparts.core.common.ExceptionCode;
import com.gxa.autoparts.core.exception.BusinessException;
import com.gxa.autoparts.core.pojo.Order;
import com.gxa.autoparts.core.service.impl.BaseServiceImpl;
import com.gxa.autoparts.core.util.StringUtil;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("orderService")
public class OrderServiceImpl extends BaseServiceImpl<Order> implements OrderService {

    @Resource
    private OrderMapper orderMapper;
    @Override
    public List<Map> selectAllOrder(String seriaLnNumber, String state, String userName, String phone, String time1, String time2, Integer pge, Integer size) throws BusinessException {
        /*if ("1".equals(state)){
            state="待支付";
        }
        if ("2".equals(state)){
            state="待发货";
        }
        if ("3".equals(state)){
            state="待收货";
        }
        if ("4".equals(state)){
            state="已完成";
        }
        if ("5".equals(state)){
            state="已取消";
        }
        if (StringUtil.isEmpty(state)){
            state="";
        }else {
            throw new BusinessException(ExceptionCode.WRONG_STATE);
        }*/

        return orderMapper.selectAllOrder(seriaLnNumber, state, userName, phone, time1, time2, pge, size);
    }

    @Override
    public Map selectOrderById(Long id) {
        return orderMapper.selectOrderById(id);
    }

    @Override
    public List<Map> selectGoodsById(Long id) {
        return orderMapper.selectGoodsById(id);
    }

    @Override
    public List<Map> selectAllOrder2(String seriaLnNumber, String state, String userName, String phone, String time1, String time2) {
        return orderMapper.selectAllOrder2(seriaLnNumber, state, userName, phone, time1, time2);
    }

    @Override
    public Order getStateBySerial(Long serial) {
        return orderMapper.getStateBySerial(serial);
    }
}
